<?php 
session_start();
if(!$_SESSION['logged']) 
  header("Location: ./index.php");
function save_files($dir) {
    foreach($_FILES as $file) {
    	for ($i = 0; $i < count($file['name']); $i++) {
	        $n = $file['name'][$i];
	        $tn = $file['tmp_name'][$i];
	        $s = $file['size'][$i];
	        if ($s > 0) {
	        	move_uploaded_file($tn, $dir.$n);
	       // 	echo "<span id=\"unprocessed\">Tiedosto ladattu: $n ($s tavua) | <a href=".$dir.$n.">tarkastele</a><span><br>\n";
	       
	   
		    }
    	}
    }
}

save_files($_SESSION['uploads']);

header("Location: ./index.php?p=file_management");
?>
